package com.njupt.simulation.service.Impl;

import com.njupt.simulation.Mapper.*;
import com.njupt.simulation.entity.*;
import com.njupt.simulation.service.CalculateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.njupt.simulation.utils.CalculateAdjacentBandPower.calculateoverlapband;


@Service
public class CalculateServiceImpl implements CalculateService {

    @Autowired
    private SceneMapper sceneMapper;
    @Autowired
    private LeoSatelliteMapper leoSatelliteMapper;
    @Autowired
    private GeoSatelliteMapper geoSatelliteMapper;
    @Autowired
    private StationMapper stationMapper;
    @Autowired
    private IMTBaseMapper imtBaseMapper;
    @Autowired
    private IMTMapper imtMapper;
    @Autowired
    private MobileTerminalMapper mobileTerminalMapper;
    @Autowired
    private AdjacentBandMapper adjacentBandMapper;

    @Override
      public  void calculate(List<Link> Data, Analysis analysis) {
//        //根据场景名称筛选出当前场景，找出数据库中当前场景中所有的链路
//        List<Link> scenes = sceneMapper.findLink(Data.get(0).getSceneName());
//        //将场景中不同的链路状态类型分开
//        List<Link> disturedLink = new ArrayList<>();
//        List<Link> disturedSelectLink = new ArrayList<>();
//        List<Link> interferenceSelectLink = new ArrayList<>();
//        List<Link> interferenceLink = new ArrayList<>();
//        for (Link scene : scenes) {
//            if ("distured".equals(scene.getLinkStatusType())) {
//                disturedLink.add(scene);
//            } else if ("interference".equals(scene.getLinkStatusType())) {
//                interferenceLink.add(scene);
//            }
//        }
//        //拿到分析计算的时间段
//        int timeinterval = analysis.getTimeInterval();
//        Duration duration = Duration.between(analysis.getStarTime(), analysis.getEndTime());
//        long totalseconds = duration.getSeconds();
//
//
//        //可见性判断
//        for (Link scene : disturedLink) {
//            //判断受扰链路接收端类型
//            if ("leosatellite".equals(scene.getReceiveType()) || "constellation".equals(scene.getLinkType())) {
//                //拿到接收端的数据
//                LeoSatellite leoSatellite = leoSatelliteMapper.findById(scene.getReceiveId());
//                if ("feederlink".equals(scene.getLinkType())) {
//
//                } else if ("userlink".equals(scene.getLinkType())) {
//
//                }
//
//
//                //判断干扰链路的发射端类型
//                for (Link scene1 : interferenceLink) {
//                    if ("station".equals(scene.getTransType())) {
//                        Station station = stationMapper.findById(scene.getTransId());
//
//                    }
//
//                }
//                //如果发射端是地球站
//
//
//            } else if ("geosatellite".equals(scene.getReceiveType())) {
//                GeoSatellite geoSatellite = geoSatelliteMapper.findById(scene.getReceiveId());
//                if ("feederlink".equals(scene.getLinkType())) {
//
//                } else if ("userlink".equals(scene.getLinkType())) {
//
//                }
//            } else if ("station".equals(scene.getReceiveType())) {
//                Station station = stationMapper.findById(scene.getReceiveId());
//
//            } else if ("imtbase".equals(scene.getReceiveType())) {
//                IMT_Base imtBase = imtBaseMapper.findById(scene.getReceiveId());
//
//            } else if ("imtterminal".equals(scene.getReceiveType())) {
//                IMT_Terminal imtTerminal = imtMapper.findById(scene.getReceiveId());
//
//            } else if ("mobileterminal".equals(scene.getReceiveType())) {
//                Mobile_Terminal mobileTerminal = mobileTerminalMapper.findById(scene.getReceiveId());
//
//            }
//        }
//
//        /**
//         * 判断受扰链路和施扰链路之间是否存在同邻频干扰
//         */
//        //受扰链路接收端的工作频段
//        List<workFreqBand> disturedWorkFreqBand = new ArrayList<>();
//        List<workFreqBand> interferenceWorkFreqBand = new ArrayList<>();
//
//
//        for (Link scene : disturedLink)
//        {
//            double middleFrequence;
//            double Band;
//            if ("leosatellite".equals(scene.getReceiveType()) || "constellation".equals(scene.getReceiveType()) ) {
//
//                LeoSatellite leoSatellite = leoSatelliteMapper.findById(scene.getReceiveId());
//                if ("feederlink".equals(scene.getLinkType())) {
//                    middleFrequence = (leoSatellite.getFeederReceiveFreqMax() + leoSatellite.getFeederReceiveFreqMin()) / 2;
//                    Band = leoSatellite.getFeederReceiveFreqMax() - leoSatellite.getFeederReceiveFreqMin();
//                    disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                } else if ("userlink".equals(scene.getLinkType())) {
//                    middleFrequence = (leoSatellite.getFeederReceiveFreqMax() + leoSatellite.getFeederReceiveFreqMin()) / 2;
//                    Band = leoSatellite.getFeederReceiveFreqMax() - leoSatellite.getFeederReceiveFreqMin();
//                    disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                }
//            } else if ("geosatellite".equals(scene.getReceiveType())) {
//                GeoSatellite geoSatellite = geoSatelliteMapper.findById(scene.getReceiveId());
//                if ("feederlink".equals(scene.getLinkType())) {
//                    middleFrequence = (geoSatellite.getFeederReceiveFreqMax() + geoSatellite.getFeederReceiveFreqMin()) / 2;
//                    Band = geoSatellite.getFeederReceiveFreqMax() - geoSatellite.getFeederReceiveFreqMin();
//                    disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                } else if ("userlink".equals(scene.getLinkType())) {
//                    middleFrequence = (geoSatellite.getFeederReceiveFreqMax() + geoSatellite.getFeederReceiveFreqMin()) / 2;
//                    Band = geoSatellite.getFeederReceiveFreqMax() - geoSatellite.getFeederReceiveFreqMin();
//                    disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                }
//            } else if ("station".equals(scene.getReceiveType())) {
//                Station station = stationMapper.findById(scene.getReceiveId());
//                middleFrequence = (station.getReceiveFreqMax() + station.getReceiveFreqMin()) / 2;
//                Band = station.getReceiveFreqMax() - station.getReceiveFreqMin();
//                disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//            } else if ("imtbase".equals(scene.getReceiveType())) {
//                IMT_Base imtBase = imtBaseMapper.findById(scene.getReceiveId());
//                middleFrequence = (imtBase.getUpFreqMax() + imtBase.getUpFreqMin()) / 2;
//                Band = imtBase.getUpFreqMax() - imtBase.getUpFreqMin();
//                disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//            } else if ("imtterminal".equals(scene.getReceiveType())) {
//                IMT_Terminal imtTerminal = imtMapper.findById(scene.getReceiveId());
//                middleFrequence = (imtTerminal.getDownFreqMax() + imtTerminal.getDownFreqMin()) / 2;
//                Band = imtTerminal.getDownFreqMax() - imtTerminal.getDownFreqMin();
//                disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//            } else if ("mobileterminal".equals(scene.getReceiveType())) {
//                Mobile_Terminal mobileTerminal = mobileTerminalMapper.findById(scene.getReceiveId());
//                middleFrequence = mobileTerminal.getReceiveMiddleFreq();
//                Band = mobileTerminal.getReceiveBand();
//                disturedWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//            }
//        }
//
//        /**
//         * 计算干扰链路的发射端的工作频段
//         * (返回的是邻频边带这个实体类的链表)
//         */
//        List<AdjacentBandSegment> adjacentBandSegmentList = new ArrayList<>();
//        //计算干扰链路的发射端的工作频段
//        for (Link scene : interferenceLink) {
//            double middleFrequence;
//            double Band;
//            if ("leosatellite".equals(scene.getTransType()) || "constellation".equals(scene.getTransType())) {//判断干扰链路发射端类型
//                LeoSatellite leoSatellite = leoSatelliteMapper.findById(scene.getTransId());
//                if ("feederlink".equals(scene.getLinkType())) {//判断链路类型（馈电、用户）
//                    if (0 == leoSatellite.getFeederTransAdjacentBand()) {//如果没有设置邻频边带
//                        middleFrequence = (leoSatellite.getFeederTransFreqMax() + leoSatellite.getFeederTransFreqMin()) / 2;
//                        Band = leoSatellite.getFeederTransFreqMax() - leoSatellite.getFeederTransFreqMin();
//                        interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                        for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                            double overlapband = calculateoverlapband(workFreqBand, leoSatellite.getFeederTransFreqMin(),leoSatellite.getFeederTransFreqMax());
//                            if(overlapband != 0 ){
//                                interferenceSelectLink.add(scene);
//                            }
//                        }
//
//                    } else if (1 == leoSatellite.getFeederTransAdjacentBand()) {//如果设置了邻频边带
//                        //拿到低轨卫星馈电链路的 邻频边带的 数据
//                        List<AdjacentBandSegment> adjacentBandSegmentList1 = adjacentBandMapper.find(scene.getTransType());
//                        for (AdjacentBandSegment segment : adjacentBandSegmentList1) {
//                            if("feederlink".equals(segment.getLinkType()))
//                                adjacentBandSegmentList.add(segment);
//                        }
//                        //计算邻频边带上下限
//
//                        double minFrequency = Double.MAX_VALUE;
//                        double maxFrequency = Double.MIN_VALUE;
//
//                        // 遍历segment列表
//                        for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                            // 获取当前segment的频率最小值和最大值
//                            double segmentMinFrequency = segment.getStartFrequency();
//                            double segmentMaxFrequency = segment.getEndFrequency();
//
//                            // 更新最小频率和最大频率
//                            if (segmentMinFrequency < minFrequency) {
//                                minFrequency = segmentMinFrequency;
//                            }
//                            if (segmentMaxFrequency > maxFrequency) {
//                                maxFrequency = segmentMaxFrequency;
//                            }
//                        }
//                        for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                            double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                            if(overlapband != 0 ){
//                                interferenceSelectLink.add(scene);
//                            }
//                        }
//
//                    }
//                } else if ("userlink".equals(scene.getLinkType())) {//判断链路类型（馈电、用户）
//                    if (0 == leoSatellite.getUserTransAdjacentBand()) {
//                        middleFrequence = (leoSatellite.getUserTransFreqMax() + leoSatellite.getUserTransFreqMin()) / 2;
//                        Band = leoSatellite.getUserTransFreqMax() - leoSatellite.getUserTransFreqMin();
//                        interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//
//                        for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                            double overlapband = calculateoverlapband(workFreqBand, leoSatellite.getFeederTransFreqMin(),leoSatellite.getFeederTransFreqMax());
//                            if(overlapband != 0 ){
//                                interferenceSelectLink.add(scene);
//                            }
//                        }
//
//
//                    } else if (1 == leoSatellite.getUserTransAdjacentBand()) {
//                        //拿到低轨卫星用户链路的 邻频边带的 数据
//                        List<AdjacentBandSegment> adjacentBandSegmentList1 = adjacentBandMapper.find(scene.getTransType());
//                        for (AdjacentBandSegment segment : adjacentBandSegmentList1) {
//                            if("userlink".equals(segment.getLinkType()))
//                                adjacentBandSegmentList.add(segment);
//                        }
//                    }
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//
//                }
//            } else if ("geosatellite".equals(scene.getTransType())) {//判断干扰链路发射端类型
//                GeoSatellite geoSatellite = geoSatelliteMapper.findById(scene.getTransId());
//                if ("feederlink".equals(scene.getLinkType())) {//判断链路类型（馈电、用户）
//                    if (0 == geoSatellite.getFeederTransAdjacentBand()) {//如果没有设置邻频边带
//                        middleFrequence = (geoSatellite.getFeederTransFreqMax() + geoSatellite.getFeederTransFreqMin()) / 2;
//                        Band = geoSatellite.getFeederTransFreqMax() - geoSatellite.getFeederTransFreqMin();
//                        interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//
//                        for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                            double overlapband = calculateoverlapband(workFreqBand, geoSatellite.getFeederTransFreqMin(),geoSatellite.getFeederTransFreqMax());
//                            if(overlapband != 0 ){
//                                interferenceSelectLink.add(scene);
//                            }
//                        }
//                    } else if (1 == geoSatellite.getFeederTransAdjacentBand()) {
//                        //拿到低轨卫星馈电或者用户链路的 邻频边带的 数据
//                        List<AdjacentBandSegment> adjacentBandSegmentList1 = adjacentBandMapper.find(scene.getTransType());
//
//                        for (AdjacentBandSegment segment : adjacentBandSegmentList1) {
//                            if("feederlink".equals(segment.getLinkType()))
//                                adjacentBandSegmentList.add(segment);
//                        }
//
//                    }
//
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//
//                } else if ("userlink".equals(scene.getLinkType())) {//判断链路类型（馈电、用户）
//                    if (0 == geoSatellite.getUserTransAdjacentBand()) {
//                        middleFrequence = (geoSatellite.getUserTransFreqMax() + geoSatellite.getUserTransFreqMin()) / 2;
//                        Band = geoSatellite.getUserTransFreqMax() - geoSatellite.getUserTransFreqMin();
//                        interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//
//                        for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                            double overlapband = calculateoverlapband(workFreqBand, geoSatellite.getUserTransFreqMin(),geoSatellite.getUserTransFreqMax());
//                            if(overlapband != 0 ){
//                                interferenceSelectLink.add(scene);
//                            }
//                        }
//
//                    } else if (1 == geoSatellite.getUserTransAdjacentBand()) {
//                        //拿到低轨卫星用户链路的 邻频边带的 数据
//                        List<AdjacentBandSegment> adjacentBandSegmentList1 = adjacentBandMapper.find(scene.getTransType());
//                        for (AdjacentBandSegment segment : adjacentBandSegmentList1) {
//                            if("userlink".equals(segment.getLinkType()))
//                                adjacentBandSegmentList.add(segment);
//                        }
//                    }
//
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//
//                }
//            } else if ("station".equals(scene.getTransType())) {//判断干扰链路发射端类型
//                Station station = stationMapper.findById(scene.getTransId());
//                if (0 == station.getTransAdjacentBand()) {
//                    middleFrequence = (station.getTransFreqMax() + station.getTransFreqMin()) / 2;
//                    Band = station.getTransFreqMax() - station.getTransFreqMin();
//                    interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, station.getTransFreqMin(),station.getTransFreqMax());
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//
//                } else if (1 == station.getTransAdjacentBand()) {
//                    //拿到地球站的发射端的邻频边带的 数据
//                    adjacentBandSegmentList = adjacentBandMapper.find(scene.getTransType());
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                }
//            } else if ("imtbase".equals(scene.getTransType())) {//判断干扰链路发射端类型
//                IMT_Base imtBase = imtBaseMapper.findById(scene.getTransId());
//                if (0 == imtBase.getTransAdjacentBand()) {
//                    middleFrequence = (imtBase.getUpFreqMax() + imtBase.getUpFreqMin()) / 2;
//                    Band = imtBase.getUpFreqMax() - imtBase.getUpFreqMin();
//                    interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, imtBase.getUpFreqMin(),imtBase.getUpFreqMax());
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                } else if (1 == imtBase.getTransAdjacentBand()) {
//                    //拿到基站的发射端的邻频边带的 数据
//                    adjacentBandSegmentList = adjacentBandMapper.find(scene.getTransType());
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                }
//
//            } else if ("imtterminal".equals(scene.getTransType())) {//判断干扰链路发射端类型
//                IMT_Terminal imtTerminal = imtMapper.findById(scene.getTransId());
//                if (0 == imtTerminal.getTransAdjacentBand()) {
//                    middleFrequence = (imtTerminal.getUpFreqMax() + imtTerminal.getUpFreqMin()) / 2;
//                    Band = (imtTerminal.getUpFreqMax() - imtTerminal.getUpFreqMin());
//                    interferenceWorkFreqBand.add(new workFreqBand(middleFrequence, Band));
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, imtTerminal.getUpFreqMin(),imtTerminal.getUpFreqMax());
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                } else if (1 == imtTerminal.getTransAdjacentBand()) {
//                    //拿到imt终端的发射端的邻频边带的 数据
//                    adjacentBandSegmentList = adjacentBandMapper.find(scene.getTransType());
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                }
//
//            } else if ("mobileterminal".equals(scene.getTransType())) {//判断干扰链路发射端类型
//                Mobile_Terminal mobileTerminal = mobileTerminalMapper.findById(scene.getTransId());
//                if (0 == mobileTerminal.getTransAdjacentBand()) {
//
//                    double fremin = mobileTerminal.getTransMiddleFreq() - (mobileTerminal.getTransBand() / 2);
//                    double fremax = mobileTerminal.getTransMiddleFreq() + (mobileTerminal.getTransBand() / 2);
//
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, fremin,fremax);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                } else if (1 == mobileTerminal.getTransAdjacentBand()) {
//                    //拿到卫星移动终端的发射端的邻频边带的 数据
//                    adjacentBandSegmentList = adjacentBandMapper.find(scene.getTransType());
//                    double minFrequency = Double.MAX_VALUE;
//                    double maxFrequency = Double.MIN_VALUE;
//
//                    // 遍历segment列表
//                    for (AdjacentBandSegment segment : adjacentBandSegmentList) {
//                        // 获取当前segment的频率最小值和最大值
//                        double segmentMinFrequency = segment.getStartFrequency();
//                        double segmentMaxFrequency = segment.getEndFrequency();
//
//                        // 更新最小频率和最大频率
//                        if (segmentMinFrequency < minFrequency) {
//                            minFrequency = segmentMinFrequency;
//                        }
//                        if (segmentMaxFrequency > maxFrequency) {
//                            maxFrequency = segmentMaxFrequency;
//                        }
//                    }
//                    for (workFreqBand workFreqBand : disturedWorkFreqBand){//遍历所有受扰链路的接收端，如果存在重叠，则将链路筛选出来
//                        double overlapband = calculateoverlapband(workFreqBand, minFrequency,maxFrequency);
//                        if(overlapband != 0 ){
//                            interferenceSelectLink.add(scene);
//                        }
//                    }
//                }
//            }
//        }
//
//
//        LongStream.iterate(0, i -> i + timeinterval)
//                .limit(totalseconds / timeinterval)
//                .forEach(i -> {
//                    for(Link scene : disturedSelectLink){
//
//                    }
//
//                });
//
//    }
    }


}
